﻿Imports System.Runtime.CompilerServices

''' <summary>
''' ICollection拡張メソッド
''' </summary>
''' <remarks></remarks>
Public Module ICollectionExtension

    ''' <summary>
    ''' クエリに変換します
    ''' </summary>
    ''' <typeparam name="T"></typeparam>
    ''' <param name="source"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()>
    Public Function ToQuery(Of T)(source As ICollection(Of T)) As Query(Of T)
        Dim lst = DirectCast(source, LoadableList(Of T))
        Return lst.Query
    End Function

    ''' <summary>
    ''' クエリに変換します
    ''' </summary>
    ''' <typeparam name="T"></typeparam>
    ''' <param name="source"></param>
    ''' <param name="loader"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()>
    Public Function ToQuery(Of T)(source As ICollection(Of T), loader As Loader) As Query(Of T)
        Dim lst = DirectCast(source, LoadableList(Of T))
        lst.Loader = loader
        Return lst.Query
    End Function

End Module

